<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
      思路：先对两个数组进行去重，然后遍历其中一个，判断另外一个数组中是否存在，存在存入res
      */
      var intersection = function (nums1, nums2) {
        let set1 = new Set(nums1)
        let set2 = new Set(nums2)
        let res = []
        for (let i of set1) {
          if (set2.has(i)) {
            res.push(i)
          }
        }
        return res
      }
    </script>
  </body>
</html>
